package com.lancoo.answer.util.paperUtils.fragmentUtils.child;

import android.text.TextUtils;
import android.util.Log;

import androidx.fragment.app.Fragment;

import com.lancoo.answer.model.bean.Child;
import com.lancoo.answer.model.bean.Ques;
import com.lancoo.answer.ui.child.lookReview.ChildClozeLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildFillLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildMatchLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildReadMatchLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildSelectLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildWordListenWriteLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.CompositionLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.PassageDictationLookReviewFragment;
import com.lancoo.answer.ui.ques.WaitToDockFragment;
import com.lancoo.answer.view.fragment.listenmatch.ListenMatchAnalysisFragment;
import com.lancoo.answer.view.fragment.listenmatch.ListenParagraphAnalysisFragment;
import com.lancoo.answer.view.fragment.option.MultiChildFragment;
import com.lancoo.answer.view.fragment.paragraphSort.ParagraphSortingChildLookingFragment;
import com.lancoo.answer.view.fragment.webquesBody.WebQuesBodyLookingFragment;
import com.lancoo.answer.view.fragment.translate.TranslateChapterAnswerLookingFragment;

/**
 * Created by pengmi on 2022/2/20 11:49
 * Description:小题查看评阅状态fragment加载
 */
public class ChildLookingFragmentUtils {

    public static Fragment loadChildLookingFragment(Ques ques,
                                                    int typeIndex,
                                                    int quesIndex,
                                                    int childIndex,
                                                    int defaultLoadIndex,int defaultLoadChildexIndex,int defaultLoadItemIndex) {
        String genreID = ques.getGenreID();
        String typeNo = ques.getTypeNo();
        Child child = ques.getChildList().get(childIndex);
        int childAnswerType = child.getChildAnswerType();
        Log.e("666", "查看作答");

//        if (ConstantBean.Companion.getTaskControlBean().isManu()){
//            switch (typeNo){
//                case "f":
//                    return ManualAnswerLookingFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
//            }
//        }
        switch (genreID) {
            case "38"://句子英译中
            case "25"://英译中
            case "40"://句子中译英
            case "26"://中译英
            case "98"://看情景写句子
            case "99"://看图写句子
                return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "43"://段落匹配
                return ChildMatchLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex, defaultLoadIndex);
            case "42"://阅读匹配
                return ChildReadMatchLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "20"://选词填空
                int childSize = ques.getChildList().size();
                int itemSize = ques.getChildList().get(0).getItemList().size();
                if (childSize > itemSize) {//句子场景
                    return ChildFillLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                } else {//短文场景
                    return WebQuesBodyLookingFragment.Companion.loadFragment(typeIndex, quesIndex, 0, defaultLoadIndex);
                }
            case "45"://多项对应
                return ParagraphSortingChildLookingFragment.Companion.loadFragment(typeIndex, quesIndex, childIndex, defaultLoadIndex);
            case "VD"://词汇听写
                return ChildWordListenWriteLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "78"://复合写作
                switch (childAnswerType) {
                    case 3:
                        return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                    case 4:
                        return CompositionLookReviewFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
                }
            case "107"://词汇翻译
                return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
        }
        switch (typeNo) {
            case "f"://作文题
                return CompositionLookReviewFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
            case "W"://短文听写
            case "V"://连词成句
                return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "S"://听力填空
            case "Q":
                String sortIndexType = child.getSortIndexType();
                if (TextUtils.equals(sortIndexType, "0")) {//如果是小题的查看原题
                    return ChildFillLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                }
                return WebQuesBodyLookingFragment.Companion.loadFragment(typeIndex, quesIndex, childIndex, defaultLoadItemIndex);
            case "C"://语法选择，完形填空，对话选择
                return ChildClozeLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "D"://阅读理解，阅读判断
                return ChildSelectLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "E": //听力选择
                if (TextUtils.isEmpty(child.getChildAsk())) {
                    return ChildClozeLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                } else {
                    return ChildSelectLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                }
            case "N":
                return ChildFillLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "g": //翻译题
                return TranslateChapterAnswerLookingFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
            case "k"://匹配加简答，匹配加选择
                switch (childAnswerType) {
                    case 0:
                        return ChildSelectLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                    case 1:
                        return  MultiChildFragment.Companion.loadFragment(typeIndex, quesIndex, defaultLoadIndex);
                    case 2:
                    case 3:
                        return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                }
            case "L"://听力综合
                return ListenMatchAnalysisFragment.Companion.loadFragment(typeIndex, quesIndex, childIndex, defaultLoadIndex);
            case "x"://听力匹配
                return ListenParagraphAnalysisFragment.Companion.loadFragment(typeIndex, quesIndex, defaultLoadItemIndex);
            case "X"://阅读简答、拓展表达
                if (TextUtils.equals("107", ques.getSpecialFeatureCodes())) {
                    switch (childAnswerType) {
                        case 3:
                            return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                        case 4:
                            return CompositionLookReviewFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
                    }
                }
                return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
        }

        switch (childAnswerType) {
            case 1:
                return ChildSelectLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case 2:
            case 4:
                return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            default:
                return new WaitToDockFragment();
        }
    }
}
